"use strict"
!function (win) {
    class Vue{
        constructor(option = {}) {
            this.$option = option
            this.$data = option.data
            this.$el = document.querySelector(this.$option.el)

            this.$proxyData()

            // 数据劫持
            new Observer(this)

        }

        // dom 挂载
        $mount() {
            new Compiler(this)
        }

        // 数据代理
        $proxyData() {
            if (!this.$data || !utils.isObject(this.$data)) {
                console.error('option.data 必须时对象')
                return
            }
            Object.keys(this.$data).forEach((key) => {
                Object.defineProperty(this, key, {
                    get() {
                        return this.$data[key]
                    },
                    set(val) {
                        this.$data[key] = val
                    }
                })
            })
        }
    }

    win.Vue = Vue
}(window)
